home *** CD-ROM | disk | FTP | other *** search
- #ifdef __STDC__
- static char sccs_id[] = "@(#) system.c 1.2 "__DATE__" HJR";
- #else
- static char sccs_id[] = "@(#) system.c 1.2 13/6/91 HJR";
- #endif
-
- /* system.c (c) Copyright 1990 H.Rogers */
-
- #include <stdlib.h>
- #include <string.h>
-
- #include "sys/param.h"
-
- extern int execl(char *,...);
- extern int wait(int *);
- extern int vfork(void);
- extern void _exit(int);
-
- #ifdef __STDC__
- int system(const char *command)
- #else
- int system(command)
- const char *command;
- #endif
- {
- int w = 0;
-
- if (!command) return(-1);
-
- switch (vfork())
- {
- case -1:
- return(-1);
- break;
- case 0:
- {
- char *shell,*path;
-
- #ifdef ARCH
- if (!(path = getenv("SHELL")))
- {
- if (*command == '*')
- execl((char *)command,0);
- else
- execl("*","",(char *)command,0);
- _exit(1);
- }
- #else
- if (!(path = getenv("SHELL"))) path = "/bin/sh";
- #endif
- shell = strrchr(path,'/'); if (shell) shell++; else shell = path;
- execl(path,shell,"-c",(char *)command,0);
- _exit(1);
- }
- break;
- default:
- wait(&w);
- break;
- }
-
- return(w>>8);
- }
-